#include <iostream>
using namespace std;

//基类
class A
{
public:
	virtual void BuySticket()
	{
		cout << "半价票" << endl;
	}

	void Print()
	{
		cout << _type << endl;
	}
public:
	char _type = 'a';
};

//派生类
class B :public A
{
public:
	virtual void BuySticket()
	{
		cout << "全价票" << endl;
	}
public:
	int _type = 'b';
};

int main()
{
    B().Print(); //打印结果：a
    cout<<B()._type; // b
    //虽然基类中的成员变量_type和派生类中成员变量_type构成了隐藏关系(重定义)，由于Print函数参数是
    //A*类型因此_type是基类的成员变量
    //仅仅B()._type则是B中的_type,可通过子类B().A::_type访问A中的_type成员
    return 0;
}

class A
{
public:
    A()
    {}
    virtual void func1()
    {
        cout << "A" << endl;
    }
    virtual void func2()
    {
        cout << "mmmm" << endl;
    }
    virtual ~A()
    {
        cout << "kkk";
        cout << "kk";
    }
    int a;
};
class B : public A
{
public:
    B()
    {}
    virtual void func1()
    {
        cout << "B" << endl;
    }
    int b;
    ~B()
    {
        cout << 89;
    }
};
class C : public B
{
public:
    void func1()
    {
        cout << "lll" << endl;
    }
    virtual void func2()
    {
        cout << "kkkk" << endl;
    }
    ~C()
    {
        cout << 90;
    }
    int c;
};
int main()
{
   /* A a;
    B b;
    C c;*/
    C* c_ptr = new C();
    A* a_ptr = c_ptr;
    B* b_ptr = c_ptr;
    a_ptr->func1();
    a_ptr->func2();
    delete c_ptr;
    return 0;
}